package com.sxf.core.db.common;

import com.baomidou.mybatisplus.generator.config.querys.MySqlQuery;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @author
 * @title: MySqlExtendQuery
 * @projectName
 * @description: TODO
 * @date
 */
public class MySqlExtendQuery extends MySqlQuery {
    public MySqlExtendQuery() {
        super();
    }

    @Override
    public String tablesSql() {
        return super.tablesSql();
    }

    @Override
    public String tableFieldsSql() {
        return "SELECT\n" +
                "\tCOLUMN_NAME AS FIELD,\n" +
                "\tCASE DATA_TYPE \n" +
                "\t\tWHEN 'text' THEN\n" +
                "\t\t'longvarchar' \n" +
                "\t\tWHEN 'json' THEN\n" +
                "\t\t'varchar' \n" +
                "\t\tELSE DATA_TYPE \n" +
                "\tEND AS TYPE,\n" +
                "\tCOLLATION_NAME AS `COLLATION`,\n" +
                "\tIS_NULLABLE AS `NULL`,\n" +
                "\tCOLUMN_KEY AS `KEY`,\n" +
                "\tCOLUMN_DEFAULT AS `DEFAULT`,\n" +
                "\tEXTRA,\n" +
                "\t`PRIVILEGES`,\n" +
                "\tCOLUMN_COMMENT AS `COMMENT` \n" +
                "FROM\n" +
                "\tINFORMATION_SCHEMA.COLUMNS \n" +
                "WHERE\n" +
                "\ttable_name = '%s'";
    }

    @Override
    public String tableName() {
        return super.tableName();
    }

    @Override
    public String tableComment() {
        return super.tableComment();
    }

    @Override
    public String fieldName() {
        return super.fieldName();
    }

    @Override
    public String fieldType() {
        return super.fieldType();
    }

    @Override
    public String fieldComment() {
        return super.fieldComment();
    }

    @Override
    public String fieldKey() {
        return super.fieldKey();
    }

    @Override
    public boolean isKeyIdentity(ResultSet results) throws SQLException {
        return super.isKeyIdentity(results);
    }
}
